<!--
描述：教学场地组件
开发人：fwb
开发日期：2017年8月22日
-->
<template lang="pug">
    keep-alive
        el-tabs(@tab-click="handleClick" v-model="activeName")
            template(v-for="(tab,index1) in tabNames")
                el-tab-pane(v-bind:label="tab" bind:name="index1" style="height:800px")
                    kalix-table(bizKey="teachSpace" ref="tabsTable" title='教学场地信息'  v-bind:tableFields="tableFields[index1]" v-bind:targetURL="targetURL"
                    v-bind:toolbarBtnList="toolbarBtnList"  v-bind:customToolBar="customToolBar"
                    v-bind:bizDialog="bizDialog" v-bind:bizSearch="'TeachSpaceSearch'" v-bind:btnList="btnList" v-bind:dictDefine="dictDefine"
                    v-bind:jsonStr="jsonStr" v-bind:isFixedColumn="isFixedColumn")
</template>

<script type="text/ecmascript-6">
    import FormModel from './model'
    import {TeachSpaceURL, ToolButtonList} from '../../config.toml'

    export default {
        name: 'kalix-educational-teachspace',
        data() {
            return {
                btnList: ToolButtonList,
                toolbarBtnList: [
                    {id: 'add', isShow: false},
                    {id: 'addTeachSpace', title: '添加', isShow: true, icon: 'icon-add'}
                ],
                dictDefine: [{ // 定义数据字典的显示
                    cacheKey: 'EDUCATIONAL-DICT-KEY',
                    type: '教室类型',
                    targetField: 'typeName',
                    sourceField: 'type'
                }, {
                    cacheKey: 'EDUCATIONAL-DICT-KEY',
                    type: '使用单位',
                    targetField: 'sydwName',
                    sourceField: 'sydw'
                }, {
                    cacheKey: 'EDUCATIONAL-DICT-KEY',
                    type: '状态',
                    targetField: 'ztName',
                    sourceField: 'zt'
                }, {
                    cacheKey: 'EDUCATIONAL-DICT-KEY',
                    type: '场地类型',
                    targetField: 'cdlxname',
                    sourceField: 'cdlx'
                }],
                targetURL: TeachSpaceURL,
                bizDialog: [
                    {id: 'view', dialog: 'TeachSpaceView'},
                    {id: 'edit', dialog: 'TeachSpaceUpdate'},
                    {id: 'addTeachSpace', dialog: 'TeachSpaceAdd'}
                ],
                tableFields: [
                    [
                        {prop: 'cdlxname', label: '场地类型'},
                        {prop: 'szxqname', label: '所在校区'},
                        {prop: 'loufangname', label: '楼房'},
                        {prop: 'lc', label: '楼层'},
                        {prop: 'mph', label: '门牌号'},
                        {prop: 'mc', label: '名称'},
                        {prop: 'typeName', label: '类型'},
                        {prop: 'rl', label: '容量'},
                        {prop: 'ztName', label: '状态'},
                        {prop: 'sydwName', label: '使用单位'},
                        {prop: 'mrgcrl', label: '默认考场容量'},
                        {prop: 'bz', label: '备注'}
                    ],
                    [
                        {prop: 'cdlxname', label: '场地类型'},
                        {prop: 'szxqname', label: '所在校区'},
                        {prop: 'loufangname', label: '楼房'},
                        {prop: 'lc', label: '楼层'},
                        {prop: 'mph', label: '门牌号'},
                        {prop: 'sys', label: '实验室'},
                        {prop: 'yxbm', label: '院（系）/部'},
                        {prop: 'zdmj', label: '占地面积'},
                        {prop: 'jzmj', label: '建筑面积'},
                        {prop: 'symj', label: '使用面积'},
                        {prop: 'ztName', label: '状态'},
                        {prop: 'bz', label: '备注'}
                    ]
                ],
                isFixedColumn: true,
                jsonStr: '{cdlx: 0}',
                tabNames: [],
                activeName: '',
                tabsTable: ''
            }
        },
        components: {},
        created() {
        },
        mounted() {
            this.tabNames = this.$M_DictKeyValueObject(`EDUCATIONAL-DICT-KEY`, `场地类型`)
        },
        computed: {},
        methods: {
            handleClick(tab, event) {
                this.jsonStr = '{cdlx: ' + tab.index + '}'
                this.formModel = Object.assign({}, FormModel)
                this.formModel.cdlx = tab.index * 1
                this.$refs.tabsTable[tab.index].getData()
            },
            customToolBar(btnId, table) {
                switch (btnId) {
                    case 'addTeachSpace': {
                        this.onAddTeachSpance(table)
                        break
                    }
                }
            },
            onAddTeachSpance(table) {
                let dig =
                    table.bizDialog.filter((item) => {
                        return item.id === 'addTeachSpace'
                    })

                table.whichBizDialog = dig[0].dialog
                setTimeout(() => {
                    if (this.formModel == null) {
                        this.formModel = Object.assign({}, FormModel)
                    }
                    table.$refs.kalixDialog.$refs.kalixBizDialog.open('添加', false, this.formModel)
                }, 20)
            }
        }
    }
</script>

<style scoped lang="stylus">
</style>
